package com.viettel.core.bussiness.cms;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.viettel.core.dao.cms.ProvinceDAO;
import com.viettel.core.entities.cms.District;
import com.viettel.core.entities.cms.Province;
import com.viettel.core.entities.cms.Ward;
import com.viettel.core.exceptions.BusinessException;
import com.viettel.core.exceptions.DataAccessException;

public class ProvinceMgrImpl implements ProvinceMgr{

	@Autowired
	ProvinceDAO provinceDAO;
	
	@Override
	public List<Province> getAllProvinces() throws BusinessException {
		try {
			return provinceDAO.getAllProvinces();
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}

	@Override
	public List<District> getListDistrictByProvince(Integer provinceId)
			throws BusinessException {
		try {
			return provinceDAO.getListDistrictByProvince(provinceId);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}

	@Override
	public Province getProvinceById(Integer id) throws BusinessException {
		try {
			return provinceDAO.getProvinceById(id);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}

	@Override
	public District getDistrictById(Integer id) throws BusinessException {
		try {
			return provinceDAO.getDistrictById(id);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}

	@Override
	public List<Ward> getListWardByDistrict(Integer districtId)
			throws BusinessException {
		try {
			return provinceDAO.getListWardByDistrict(districtId);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}

	@Override
	public Ward getWardById(Integer id) throws BusinessException {
		try {
			return provinceDAO.getWardById(id);
		} catch (DataAccessException e) {
			throw new BusinessException(e);
		}
	}

}
